# -*- coding: utf-8 -*-
# https://blog.csdn.net/weixin_52040868
# 公众号：测个der
# 微信：qing_an_an

from PyQt5.QtWidgets import *
import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *


class Bar(QMainWindow):
    def __init__(self):
        super(Bar, self).__init__()

        # 实例化菜单栏
        bar = self.menuBar()
        # 添加父菜单
        file = bar.addMenu("File")
        # 添加子菜单
        file.addAction("show")
        file.triggered[QAction].connect(self.processTrigger)

        self.setCentralWidget(QTextEdit())
        self.statusBar = QStatusBar()
        # 设置状态栏，类似布局设置
        self.setStatusBar(self.statusBar)

    def processTrigger(self, q):
        if (q.text() == 'show'):
            # 设置状态栏的显示文本以及显示时间
            self.statusBar.showMessage(q.text() + '菜单选项被点击了', 5000)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    bar = Bar()
    bar.show()
    sys.exit(app.exec_())
